home *** CD-ROM | disk | FTP | other *** search
- // Copyright (C) 1997-2002 Alias|Wavefront,
- // a division of Silicon Graphics Limited.
- //
- // The information in this file is provided for the exclusive use of the
- // licensees of Alias|Wavefront. Such users have the right to use, modify,
- // and incorporate this code into other products for purposes authorized
- // by the Alias|Wavefront license agreement, without fee.
- //
- // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
- // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
- // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
- // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
- // PERFORMANCE OF THIS SOFTWARE.
- //
- //
- // Alias|Wavefront Script File
- //
- // Creation Date: June 5, 1997
- // Author: sw
- //
- // Procedure Name:
- // AEtangentConstraintTemplate
- //
- // Description Name;
- // Creates the attribute editor controls for the tangentConstraint Node
- //
- // Input Value:
- // nodeName
- //
- // Output Value:
- // None
- //
-
- global string $gAEtangentConstraintWorldUpWidgets[]; // hold info plus widgets
-
- global proc AEenableRestTangentCallback( string $nodeName )
- {
- int $enable = `getAttr ($nodeName+".enableRestPosition")`;
- editorTemplate -dimControl $nodeName "restRotate" (! $enable);
- }
-
- global proc AEtangentConstraintTemplate ( string $nodeName )
- {
- editorTemplate -beginScrollLayout;
-
- // include/call base class/node attributes
- AEtransformMain $nodeName;
-
- editorTemplate -beginLayout "Tangent Constraint Attributes" -collapse 0;
-
- editorTemplate -addControl "aimVector";
- editorTemplate -addControl "upVector";
- editorTemplate -addControl "worldUpType"
- "AEtangentConstraintWorldUpControls";
- editorTemplate -addControl "worldUpVector";
- editorTemplate -callCustom
- "AEtangentConstraintWorldUpObjectNew"
- "AEtangentConstraintWorldUpObjectReplace"
- "worldUpMatrix";
-
- editorTemplate -addSeparator;
-
- editorTemplate -addControl "constraintRotate";
- editorTemplate -addControl "constraintVector";
- editorTemplate -addControl "enableRestPosition" "AEenableRestTangentCallback";
- editorTemplate -addControl "restRotate";
-
- editorTemplate -endLayout;
-
- // include/call base class/node attributes
- AEtransformNoScroll $nodeName;
-
- // supressed attributes
- editorTemplate -suppress "constraintRotateOrder";
- editorTemplate -suppress "constraintTranslate";
- editorTemplate -suppress "constraintRotatePivot";
- editorTemplate -suppress "constraintJointOrient";
- editorTemplate -suppress "constraintParentInverseMatrix";
- editorTemplate -suppress "worldUpType";
- // editorTemplate -suppress "worldUpVector";
- editorTemplate -suppress "worldUpMatrix";
- editorTemplate -suppress "target";
- editorTemplate -suppress "constraintRotateTranslate";
-
- editorTemplate -addExtraControls;
- editorTemplate -endScrollLayout;
- }
-
- proc setStateOfWorldUpObjectControls( string $nodeName, int $state )
- {
- global string $gAEtangentConstraintWorldUpWidgets[];
-
- // Update the world up object text field for all attribute
- // editors looking at this node
-
- int $i;
- for ($i = 0; $i < size($gAEtangentConstraintWorldUpWidgets); $i += 3 )
- {
- if ( $nodeName == $gAEtangentConstraintWorldUpWidgets[$i] )
- {
- string $worldUpObjectControl = $gAEtangentConstraintWorldUpWidgets[$i+2];
- if ( `textFieldGrp -exists $worldUpObjectControl` )
- {
- textFieldGrp -e -enable $state $worldUpObjectControl;
- }
- }
- }
- }
-
- // This proc will dim/undim the world up controls as required
- global proc AEtangentConstraintWorldUpControls(string $nodeName)
- {
- $nodeAttr = $nodeName +".worldUpType";
- int $value = `getAttr $nodeAttr`;
- switch ($value)
- {
- case 0: // Scene Up
- case 4: // None
- editorTemplate -dimControl $nodeName "worldUpVector" true;
- setStateOfWorldUpObjectControls( $nodeName, false );
- break;
- case 1: // Object Up
- editorTemplate -dimControl $nodeName "worldUpVector" true;
- setStateOfWorldUpObjectControls( $nodeName, true );
- break;
- case 2: // Object Rotation Up
- editorTemplate -dimControl $nodeName "worldUpVector" false;
- setStateOfWorldUpObjectControls( $nodeName, true );
- break;
- case 3: // Vector
- editorTemplate -dimControl $nodeName "worldUpVector" false;
- setStateOfWorldUpObjectControls( $nodeName, false );
- break;
- default:
- break;
- }
- }
-
-
- // This proc gets called by the UI widget for the
- // worldUpMatrix attribute
- //
- global proc AEtangentConstraintWorldUpObjectControlProc(string $nodeName,
- string $widget)
- {
- // Get the current value of the widget
-
- string $value = `textFieldGrp -q -text $widget`;
-
- // setAttr just isn't sufficient for worldUpMatrix
-
- tangentConstraint -edit -worldUpObject $value $nodeName;
- }
-
- // This proc gets called by the scriptJob which is watching the
- // worldUpMatrix attribute
- //
- global proc AEtangentConstraintWorldUpObjectScriptJobProc(string $nodeName,
- string $widget)
- {
- textFieldGrp -e
- -text `tangentConstraint -q -worldUpObject $nodeName`
- $widget;
- }
-
- // Local proc shared by AEtangentConstraintWorldUpObjectNew() and AEtangentConstraintWorldUpObjectReplace()
- proc updateWorldUpObject( string $nodeName, string $plug, string $worldUpObjectControl )
- {
- // Initialize/update the textFieldGrp
-
- string $cmd1 = "AEtangentConstraintWorldUpObjectControlProc "+$nodeName+" "+$worldUpObjectControl;
- textFieldGrp -e
- -text `tangentConstraint -q -worldUpObject $nodeName`
- -cc $cmd1
- $worldUpObjectControl;
-
- // Setup/update the scriptJob callback mechanism
-
- string $cmd2 = "AEtangentConstraintWorldUpObjectScriptJobProc "+$nodeName+" "+$worldUpObjectControl;
- scriptJob -rp -p $worldUpObjectControl -ac $plug $cmd2;
- }
-
- // The custom creation proc for the worldUpMatrix attribute
- //
- global proc AEtangentConstraintWorldUpObjectNew( string $plug )
- {
- global string $gAEtangentConstraintWorldUpWidgets[];
-
- // Get the node name
-
- string $buffer[];
- tokenize($plug,".|",$buffer);
- string $nodeName = $buffer[0];
-
- // Save the node name and the parent info in the global
- // string array
-
- int $numTangentConstraintAEs = size($gAEtangentConstraintWorldUpWidgets);
- $gAEtangentConstraintWorldUpWidgets[$numTangentConstraintAEs] = $nodeName;
- $gAEtangentConstraintWorldUpWidgets[$numTangentConstraintAEs+1] = `setParent -q`;
-
- // Create the textFieldGrp
-
- setUITemplate -pst attributeEditorTemplate;
-
- string $worldUpObjectControl =
- `textFieldGrp -l "World Up Object" AEtangentConstraintWorldUpObjectField`;
-
- // Save the control for possible later reuse
- $gAEtangentConstraintWorldUpWidgets[$numTangentConstraintAEs+2] = $worldUpObjectControl;
-
- setUITemplate -ppt;
-
- updateWorldUpObject( $nodeName, $plug, $worldUpObjectControl );
- }
-
- global proc AEtangentConstraintWorldUpObjectReplace( string $plug )
- {
- global string $gAEtangentConstraintWorldUpWidgets[];
-
- // Get the node name
-
- string $buffer[];
- tokenize($plug,".|",$buffer);
- string $nodeName = $buffer[0];
-
- // Reuse the existing control
-
- string $curParent = `setParent -q`;
- int $index = -1;
- int $i;
- for ( $i = 0; $i < size($gAEtangentConstraintWorldUpWidgets); $i += 3 )
- {
- if ( $curParent == $gAEtangentConstraintWorldUpWidgets[$i+1] )
- {
- $index = $i;
- break;
- }
- }
- string $worldUpObjectControl = "AEtangentConstraintWorldUpObjectField";
- if ($index != -1)
- {
- $gAEtangentConstraintWorldUpWidgets[$index] = $nodeName;
- $worldUpObjectControl = $gAEtangentConstraintWorldUpWidgets[$index+2];
- }
-
- updateWorldUpObject( $nodeName, $plug, $worldUpObjectControl );
- }
-